﻿// -------------------------------------------------------------------------
//    @FileName         :    NFPackageServiceTest.h
//    @Author           :    Gao.Yi
//    @Date             :    2025-10-14
//    @Email			:    445267987@qq.com
//    @Module           :    NFPackageServiceTest
//    @Desc             :    NFServicePackage 单元测试
//
// -------------------------------------------------------------------------

#pragma once

#ifdef NF_DEBUG_MODE
#ifdef NF_STATIC_PLUGIN
#include <gtest/gtest.h>
#include "NFComm/NFCore/NFPlatform.h"
#include "NFComm/NFCore/NFRandom.hpp"

class NFPlayer;

/**
 * @brief NFServicePackage 单元测试类
 * 
 * 该类用于测试背包服务的所有接口功能
 * 包括物品的添加、删除、查询、金钱操作等核心功能
 */
class NFPackageServiceTest
{
public:
    /**
     * @brief 运行所有背包服务单元测试
     * @param pPlayer 玩家对象指针
     * @return 0表示成功
     */
    static int RunAllTests(NFPlayer* pPlayer);

private:
    // 测试分组接口
    static void TestBagPageOperations(NFPlayer* pPlayer);
    static void TestMoneyOperations(NFPlayer* pPlayer);
    static void TestAddItemOperations(NFPlayer* pPlayer);
    static void TestGetItemOperations(NFPlayer* pPlayer);
    static void TestDeleteItemOperations(NFPlayer* pPlayer);
    static void TestVirtualMoneyOperations(NFPlayer* pPlayer);
    
    // NFBagPageOpMgr 复杂操作测试
    static void TestBagPageOpMgrComplexOperations(NFPlayer* pPlayer);
    static void TestBagPageOpMgrBatchOperations(NFPlayer* pPlayer);
    static void TestBagPageOpMgrAdvancedFeatures(NFPlayer* pPlayer);
    static void TestBagPageOpMgrItemMovement(NFPlayer* pPlayer);
    static void TestBagPageOpMgrGridOperations(NFPlayer* pPlayer);
    static void TestBagPageOpMgrErrorScenarios(NFPlayer* pPlayer);
    static void TestBagPageOpMgrPerformanceTests(NFPlayer* pPlayer);
};

/**
 * @brief Google Test 测试夹具类
 * 
 * 用于设置和清理测试环境
 */
class PackageServiceTestFixture : public ::testing::Test
{
public:
    static NFPlayer* s_pPlayer;
    static std::vector<int> s_vecItemIDs; //普通可叠加物品
    static std::vector<int> s_vecEquipIDs; //装备，不可叠加
    static std::vector<int> s_vecMoneys; //货币类型
    static std::vector<int> s_vecBagTypes; //背包类型

    static int RandomItemId()
    {
        if (s_vecItemIDs.empty())
            return 0;
        int iIndex = NFRandInt(0, (int)s_vecItemIDs.size() - 1);
        return s_vecItemIDs[iIndex];
    }

    static int RandomEquipId()
    {
        if (s_vecEquipIDs.empty())
            return 0;
        int iIndex = NFRandInt(0, (int)s_vecEquipIDs.size() - 1);
        return s_vecEquipIDs[iIndex];
    }

    static int RandomBagType()
    {
        if (s_vecBagTypes.empty())
            return 0;
        int iIndex = NFRandInt(0, (int)s_vecBagTypes.size() - 1);
        return s_vecBagTypes[iIndex];
    }

    static int RandomMoneyType()
    {
        if (s_vecMoneys.empty())
            return 0;
        int iIndex = NFRandInt(0, (int)s_vecMoneys.size() - 1);
        return s_vecMoneys[iIndex];
    }

    static void SetUpTestSuite();
    static void TearDownTestSuite();

    void SetUp() override;
    void TearDown() override;
};

#endif
#endif // NF_DEBUG_MODE

